#encoding = utf-8
from time import sleep

import pytest
import requests
import json
from shargeApi.get_code import Getcode
import yaml

from shargeApi.config import url_sign
from shargeApi.login import LoginAPI
import allure

@allure.epic("sharge")
@allure.feature("signtest")
class Testusrmode:


    def setup(self):
        pass

    def teardown(self):
        pass

    with open('/Users/sen/Desktop/test_case/shargeAPI_test/shargeData/phone.txt', 'r', encoding='utf-8') as f:
        phone_numb = yaml.load(f, Loader=yaml.FullLoader)
    @allure.title("注册账号")
    @pytest.mark.parametrize('phone', phone_numb)
    def test01_sign(self,phone):
        getcode =Getcode()
        getcode.getcode(phone)
        # print(phone)
        url = url_sign
        json_data = {"code":"123456","area":"86","password":"147952la","mobile":phone}
        jsondata= json.dumps(json_data)
        headers = {"Content-Type":"application/json"}
        res = requests.post(url = url,data = jsondata.encode('utf-8'),  headers=headers)

        result = json.loads(res.text)
        print("\n---------",result)
        assert result['message'] == "成功"




